import { _decorator, Node, UITransform, Layers } from 'cc';

export function createUINode() {
    const node = new Node();

    const tranform = node.addComponent(UITransform);
    tranform.setAnchorPoint(0, 1);

    node.layer = 1 << Layers.nameToLayer('UI_2D');

    return node;
}

export function randomByRange(start: number, end: number) {
    return Math.floor(start + (end - start) * Math.random());
}

export function randomIdByLen(len: number) {
    return Array.from({ length: len }).reduce<string>((total) => total + Math.floor(Math.random() * 10), '');
}